// pages/RewardDetails/RewardDetails.js
const axios = require('../../utils/http.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pro_id: 0,
    reward: {
      monnyNum: 0,
      intentionerInfos: [{
          reward_user_id:0,
          is_source:0,
          number: 0,
          createtime: '',
          user_nickname: '',
          user_img: '',
          reward_list: [{
              get_reward_user_id:0,
              user_img: '',
              money: 0,
              user_nickname: ''
            }
          ]
        }
      ],
      publisherInfo: {
        monny: 111,
        time: '2017-12-13 12:12:12',
        name: '金宜峰发布者',
        img: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1533128365558&di=5094cd6bfcb1527fa1dbd5b7a71ecbae&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F9%2F573ac71de8c6c.jpg',
      },
      publisherRewardInfo: [{
          img: 'http://img5.imgtn.bdimg.com/it/u=2082340907,2919238696&fm=27&gp=0.jpg',
          monny: 100,
          name: '金宜峰1'
        },
        {
          img: 'http://img.7xz.com/img/picimg/201609/20160907105336_593369dbbe9e2cc6534.jpg',
          monny: 101,
          name: '金宜峰2'
        },
        {
          img: 'http://up.enterdesk.com/edpic_source/78/5b/88/785b88931df2bc905045cb1e80b8c992.jpg',
          monny: 110,
          name: '金宜峰3'
        },
        {
          img: 'http://up.enterdesk.com/edpic_360_360/ba/06/e0/ba06e0ab9118acfe6d3e76b85f2517cc.jpg',
          monny: 120,
          name: '金宜峰4'
        },
        {
          img: 'http://up.enterdesk.com/edpic_source/b2/98/93/b29893a35c603a502695b614839a337f.jpg',
          monny: 130,
          name: '金宜峰5'
        },
        {
          img: 'http://pic1.win4000.com/wallpaper/2017-12-14/5a320da179ddc.jpg',
          monny: 100,
          name: '金宜峰6'
        },
      ]
    }
  },

  personDetails: function(e) {
    var userId = e.currentTarget.dataset.aa;
    // console.log(userId)
    wx.navigateTo({
      url: '../PersonMessage/PersonMessage?userId=' + userId
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.data.pro_id = options.proId
    this.rewardDetailsHttp(options.proId)
  },

  /**
   * 打赏详情
   */
  rewardDetailsHttp: function(proId) {
    var that = this;
    var parame = {
      pro_id: 13,
      user_id: 100
    }
    axios.POST(true, 'Orders/order_reward_list', parame, function(res) {
      var numbers = 0;
      for(var i =0;i<res.length;i++){
        numbers = numbers + parseInt(res[i].number)
      }
      var rewardnew = that.data.reward;
      rewardnew.monnyNum = numbers+".00";
      rewardnew.intentionerInfos = res;
      console.log(rewardnew);
      that.setData({
        reward: rewardnew
      })
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})